$(document).ready(function () {
    cxzx.onload();
});

var cxzx = (function () {

    var init  = function () {
        //初始化页面高度
        $('.wxn_container').css("height",$(window).height() - 10 + "px");
    }

    return {
        onload:function () {
            var curseg = cxzx;
            init();
            curseg.slideChange();
            // alert($(document).height());
        },
        
        //左侧菜单栏切换
        slideChange:function(){
        	$('.wxn_list li').on('click',function(){
        		$(this).siblings().removeClass('active');
        		$(this).addClass('active');
        		if($(this).index() != 0){
                  	$(this).css({
	                        "border-top":"1px solid #e8e8e8"
	                    })
                }
        		$(this).siblings().css({
        			"border-top":"1px solid #f6fafd"
        		})
        		$("#cxzx_iframe").attr("src",$(this).attr("data-url"))
        	})
        },
         /*优惠信息弹出框表格数据交互*/
	      tableDataYhAlert: function() {
	 		var data = [{
	 				"number": "1",
	 				"zsTime":"2018-08-23",
	 				"zsxm":"增值税",
	 				"skStart":"2018-08-23",
	 				"skFinish": "2018-08-28",
	 				"sk":'320,222.00',
	 				"jmse":'1,000.00'
	 			},
	 			{
	 				"number": "2",
	 				"zsTime":"2018-08-23",
	 				"zsxm":"增值税",
	 				"skStart":"2018-08-23",
	 				"skFinish": "2018-08-28",
	 				"sk":'320,222.00',
	 				"jmse":'1,000.00'
	 			}
	 		];
	 		$('#wepYhxxAlert').DataTable({
	 			"data": data,
	 			"columns": [
	 			    {
	 					"data": "number"
	 				},
	 				{
	 					"data": "zsTime"
	 				},
	 				{
	 					"data": "zsxm"
	 				},
	 				{
	 					"data": "skStart"
	 				},
	 				{
	 					"data": "skFinish"
	 				},
	 				{
	 					"data": "sk"
	 				},{
	 					"data": "jmse"
	 				}
	 			],
	// 			"paging": false,
	 			"info": false,
	 			"ordering": false,
	 			"lengthChange": false,
	 			"searching": false
	 		});
	    },
	    /*弹出框1*/
     	alertBox:function(dom){
     		cxzx.tableDataYhAlert();
     		layui.use('layer', function(){
				var layer = layui.layer;
				layer.open({
					title:"优惠条数",
				  	type: 1,
				  	area: ['900px', 'auto'],
				  	content: $(dom), //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
					end:function(){
						dttable = $('#wepYhxxAlert').dataTable();
	                    dttable.fnClearTable(); //清空一下table
	                    dttable.fnDestroy();
					}
				});
				
			}); 
     	},
     	/*弹出框2*/
     	alertBox2:function(text,dom,dom1,dom2){
     		$(dom1).show();
     		$(dom2).hide();
     		layui.use('layer', function(){
				var layer = layui.layer;
				layer.open({
					title:text,
				  	type: 1,
				  	area: ['900px', '450px'],
				  	content: $(dom)//这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
				});
			}); 
     	}
    }
})();